package com.hh.hibernate.util.dto;

import java.util.ArrayList;
import java.util.Date;

import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression;

import com.hh.baseframework.util.Check;
import com.hh.baseframework.util.Convert;

@SuppressWarnings("serial")
public class HQLParamList extends ArrayList<Object> {
	public HQLParamList addCondition(Object criterion) {
		this.add(criterion);
		return this;
	}

	public HQLParamList addConditionFilterEmpty(SimpleExpression criterion) {
		if (Check.isEmpty(Convert.toString(criterion.getValue())
				.replaceAll("%", "").replaceAll("null", ""))) {
			return this;
		}
		this.add(criterion);
		return this;
	}
//
//	public HQLParamList addConditionDate(String propertyName, Date start,
//			Date end) {
//		this.add(Restrictions.or(Restrictions.ge(propertyName, start),
//				Restrictions.le(propertyName, end)));
//		return this;
//	}
//
//	public HQLParamList addConditionDate(String startpropertyName,
//			String endpropertyName, Date date) {
//		this.add(Restrictions.or(Restrictions.ge(startpropertyName, date),
//				Restrictions.le(endpropertyName, date)));
//		return this;
//	}
}
